﻿using AzureVMDashboard.Model;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;

namespace AzureVMDashboard.UI
{
    /// <summary>
    /// Interaction logic for VMControl.xaml
    /// </summary>
    public partial class VMControl : UserControl
    {
        public VMControl()
        {       
            InitializeComponent();           
        }

        public static readonly DependencyProperty VMProperty = DependencyProperty.Register("VM", typeof(AzureVM), typeof(VMControl));
        
        public AzureVM VM {
            get { return (AzureVM)GetValue(VMProperty); }
            set { SetValue(VMProperty,value); }
        }
      
        private void StartClick(object sender, RoutedEventArgs e)
        {
            VM.StartAsync();
        }

        private void RdpClick(object sender, RoutedEventArgs e)
        {
            Process mstsc = new Process();
            mstsc.StartInfo.FileName = "mstsc.exe";
            mstsc.StartInfo.Arguments = String.Format("/v:{0}:{1}", VM.FQDN, VM.RdpPort);
            mstsc.Start();           
        }


        private void StopClick(object sender, RoutedEventArgs e)
        {
            VM.StopAsync();
        }
    }
}
